--- /dev/null
+/*
+ Read Vito Navigator .SMT tracks
+
+ Copyright (C) 2005 Etienne TASSE
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+
+#define MYNAME "vitosmt"
+#include "defs.h"
+
+FILE *infile;
+
+static unsigned long
+ReadLong(FILE * f)
+{
+ gbuint32 result = 0;
+
+ fread(&result, sizeof (result), 1, f);
+ return le_read32(&result);
+}
+
+static double
+ReadDouble(FILE * f)
+{
+ /* unsigned char result[8] = "\0\0\0\0\0\0\0\0"; */
+ double result=0;
+
+ fread(&result, sizeof (result), 1, f);
+ return result;
+}
+
+
+static unsigned char *
+ReadRecord(FILE * f,
+ unsigned long size)
+{
+ unsigned char *result = (unsigned char *) xmalloc(size);
+
+ fread(result, size, 1, f);
+ return result;
+}
+
+static void
+Skip(FILE * f,
+ unsigned long distance)
+{
+ fseek(f, distance, SEEK_CUR);
+}
+
+static void
+rd_init(const char *fname)
+{
+ infile = xfopen(fname, "rb", MYNAME);
+}
+
+static void
+rd_deinit(void)
+{
+ fclose(infile);
+}
+
+static void
+vitosmt_read(void)
+{
+ unsigned short version =0;
+ unsigned long count =0;
+ const unsigned long recsize =64;
+ unsigned short stringlen =0;
+ static int serial =0;
+
+/* route_head *track_head =0; */
+ waypoint *wpt_tmp =0;
+ double latrad =0;
+ double lonrad =0;
+ double elev =0;
+ unsigned char* timestamp =0;
+ struct tm tmStruct ={0,0,0,0,0,0,0,0,0};
+
+ /*
+ * 24 bytes header
+ */
+ version = ReadLong(infile); /* 2 */
+ ReadLong(infile); /* 1000 */
+ count = ReadLong(infile); /* 600 */
+ ReadLong(infile); /* 0 */
+ ReadLong(infile); /* 599 */
+ ReadLong(infile); /* 600 */
+
+/* track_head = route_head_alloc(); */
+/* route_add_head(track_head); */
+
+
+ while (count) {
+ /*
+ * 64 bytes of data
+ */
+ latrad =ReadDouble(infile); /* WGS84 latitude in radians */
+ lonrad =ReadDouble(infile); /* WGS84 longitude in radians */
+ elev =ReadDouble(infile); /* elevation in meters */
+ timestamp =ReadRecord(infile,8); /* local time */
+ Skip(infile,32); /* remainder, unknown fmt */
+
+ wpt_tmp = waypt_new();
+
+ wpt_tmp->latitude =(latrad * 180) / M_PI;
+ wpt_tmp->longitude =(lonrad * 180) / M_PI;
+ wpt_tmp->altitude =elev;
+
+ tmStruct.tm_year =timestamp[0]+100;
+ tmStruct.tm_mon =timestamp[1]-1;
+ tmStruct.tm_mday =timestamp[2];
+ tmStruct.tm_hour =timestamp[3];
+ tmStruct.tm_min =timestamp[4];
+ tmStruct.tm_sec =timestamp[5];
+ tmStruct.tm_isdst =-1;
+
+ wpt_tmp->creation_time = mktime(&tmStruct); /* + get_tz_offset(); */
+
+ wpt_tmp->shortname = (char *) xmalloc(10);
+ snprintf(wpt_tmp->shortname, 10, "SMT%04d",++serial);
+ wpt_tmp->wpt_flags.shortname_is_synthetic = 1;
+
+ waypt_add(wpt_tmp);
+
+ xfree(timestamp);
+
+
+ count--;
+ }
+}
+
+static void
+wr_init(const char *fname)
+{
+ fatal(MYNAME ":Not enough information is known about this format to write it.\n");
+}
+
+ff_vecs_t vitosmt_vecs = {
+ ff_type_file,
+ { ff_cap_read, ff_cap_read, ff_cap_none},
+ rd_init,
+ wr_init,
+ rd_deinit,
+ NULL,
+ vitosmt_read,
+ NULL,
+ NULL,
+ NULL
+};